\hypertarget{compressor_8c}{}\doxysection{compressor.\+c File Reference}
\label{compressor_8c}\index{compressor.c@{compressor.c}}
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include \char`\"{}jsmn.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}picocoap.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}compressor.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}schc\+\_\+config.\+h\char`\"{}}\newline
{\ttfamily \#include \char`\"{}rules/rule\+\_\+config.\+h\char`\"{}}\newline
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
static void \mbox{\hyperlink{compressor_8c_ac1569580e90e636a6d48366af83f3164}{get\+\_\+node\+\_\+ip}} (\mbox{\hyperlink{schc_8h_a871e6877df8d1bf5f1d0690d6b918f6b}{schc\+\_\+ipaddr\+\_\+t}} $\ast$node\+\_\+ip)
\begin{DoxyCompactList}\small\item\em Get the node its IP address as set during initialization. \end{DoxyCompactList}\item 
static struct \mbox{\hyperlink{structschc__device}{schc\+\_\+device}} $\ast$ \mbox{\hyperlink{compressor_8c_ac9e32a3cb72316274db7b597a9aca407}{get\+\_\+device\+\_\+by\+\_\+id}} (uint32\+\_\+t device\+\_\+id)
\begin{DoxyCompactList}\small\item\em Get a device by it\textquotesingle{}s id. \end{DoxyCompactList}\item 
int8\+\_\+t \mbox{\hyperlink{compressor_8c_a15002a02e9cae01e5629cb2d474fe482}{set\+\_\+rule\+\_\+id}} (struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$schc\+\_\+rule, uint8\+\_\+t $\ast$data)
\item 
struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$ \mbox{\hyperlink{compressor_8c_aaf76c0525a94eecb1f694ba09b435c49}{get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+reliability\+\_\+mode}} (struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$schc\+\_\+rule, \mbox{\hyperlink{schc_8h_a00b61f9b90ab7065eb6a978141d7fd34}{reliability\+\_\+mode}} mode, uint32\+\_\+t device\+\_\+id)
\item 
static struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$ \mbox{\hyperlink{compressor_8c_ab1cdc4ecc8218636dd177a43cf85bb63}{get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+layer\+\_\+ids}} (uint8\+\_\+t ip\+\_\+rule\+\_\+id, uint8\+\_\+t udp\+\_\+rule\+\_\+id, uint8\+\_\+t coap\+\_\+rule\+\_\+id, uint32\+\_\+t device\+\_\+id, \mbox{\hyperlink{schc_8h_a00b61f9b90ab7065eb6a978141d7fd34}{reliability\+\_\+mode}} mode)
\item 
struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$ \mbox{\hyperlink{compressor_8c_a0403165232716bdd5f3a06169692c2a9}{get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+rule\+\_\+id}} (uint8\+\_\+t $\ast$rule\+\_\+arr, uint32\+\_\+t device\+\_\+id)
\item 
static uint8\+\_\+t \mbox{\hyperlink{compressor_8c_a965c3a63dd22c405c83c4164f10f9985}{compress}} (\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$dst, \mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$src, const struct \mbox{\hyperlink{structschc__layer__rule__t}{schc\+\_\+layer\+\_\+rule\+\_\+t}} $\ast$rule, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} DI)
\begin{DoxyCompactList}\small\item\em The compression mechanism. \end{DoxyCompactList}\item 
static uint8\+\_\+t \mbox{\hyperlink{compressor_8c_af8317d5d5e72076851ec7fe49688f4a7}{decompress}} (struct \mbox{\hyperlink{structschc__layer__rule__t}{schc\+\_\+layer\+\_\+rule\+\_\+t}} $\ast$rule, \mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$src, \mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$dst, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} DI)
\begin{DoxyCompactList}\small\item\em The decompression mechanism. \end{DoxyCompactList}\item 
static struct \mbox{\hyperlink{structschc__layer__rule__t}{schc\+\_\+layer\+\_\+rule\+\_\+t}} $\ast$ \mbox{\hyperlink{compressor_8c_a8137a81bb5ae333086b8aaf814b10a62}{schc\+\_\+find\+\_\+rule\+\_\+from\+\_\+header}} (\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$src, uint32\+\_\+t device\+\_\+id, \mbox{\hyperlink{schc_8h_ac6a26bb50f32ca8810179e894e284ea0}{schc\+\_\+layer\+\_\+t}} layer, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} DI)
\begin{DoxyCompactList}\small\item\em Find a matching rule for a layer. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{compressor_8c_a263bfe2b1b6914b5b715f434f154d07b}{swap\+\_\+ipv6\+\_\+source\+\_\+and\+\_\+destination}} (uint8\+\_\+t $\ast$ptr)
\begin{DoxyCompactList}\small\item\em Swaps the I\+Pv6 source and destination. \end{DoxyCompactList}\item 
static uint8\+\_\+t \mbox{\hyperlink{compressor_8c_a9991f6ae222b8d657ebb0e0b162ea282}{equal}} (struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$target\+\_\+field, unsigned char $\ast$field\+\_\+value, uint16\+\_\+t field\+\_\+offset)
\begin{DoxyCompactList}\small\item\em The equal matching operator. \end{DoxyCompactList}\item 
static uint8\+\_\+t \mbox{\hyperlink{compressor_8c_a394540a77045dcb0230079435b631960}{ignore}} (struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$target\+\_\+field, unsigned char $\ast$field\+\_\+value, uint16\+\_\+t field\+\_\+offset)
\begin{DoxyCompactList}\small\item\em The ignore matching operator. \end{DoxyCompactList}\item 
static uint8\+\_\+t \mbox{\hyperlink{compressor_8c_abd91def21b62074e08368e9bb11593d5}{M\+SB}} (struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$target\+\_\+field, unsigned char $\ast$field\+\_\+value, uint16\+\_\+t field\+\_\+offset)
\begin{DoxyCompactList}\small\item\em The M\+SB matching operator M\+S\+B(x)\+: a match is obtained if the most significant (leftmost) x bits of the packet header field value are equal to the TV in the Rule. \end{DoxyCompactList}\item 
static uint8\+\_\+t \mbox{\hyperlink{compressor_8c_a5371dbc9847ed58dc760b7f028ea14e9}{matchmap}} (struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$target\+\_\+field, unsigned char $\ast$field\+\_\+value, uint16\+\_\+t field\+\_\+offset)
\begin{DoxyCompactList}\small\item\em The match-\/map matching operator match-\/mapping\+: With match-\/mapping, the Target Value is a list of values. \end{DoxyCompactList}\item 
static void \mbox{\hyperlink{compressor_8c_a3e74925e4bb4cb937a3ac4b951f41119}{set\+\_\+node\+\_\+ip}} (\mbox{\hyperlink{schc_8h_a871e6877df8d1bf5f1d0690d6b918f6b}{schc\+\_\+ipaddr\+\_\+t}} $\ast$node\+\_\+ip)
\begin{DoxyCompactList}\small\item\em Notifies the compressor about the node its IP address. \end{DoxyCompactList}\item 
uint8\+\_\+t \mbox{\hyperlink{compressor_8c_a4fd03f3acd56b4bf55fc4c8e48567ab7}{schc\+\_\+compressor\+\_\+init}} (uint8\+\_\+t src\mbox{[}16\mbox{]})
\begin{DoxyCompactList}\small\item\em Initializes the S\+C\+HC compressor. \end{DoxyCompactList}\item 
int16\+\_\+t \mbox{\hyperlink{compressor_8c_a7b8fe3cf10dcb9935bcbc92bb1b9c8f9}{schc\+\_\+compress}} (uint8\+\_\+t $\ast$data, uint16\+\_\+t total\+\_\+length, \mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$dst, uint32\+\_\+t device\+\_\+id, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} dir, struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$$\ast$schc\+\_\+rule)
\begin{DoxyCompactList}\small\item\em Compresses a Co\+A\+P/\+U\+D\+P/\+IP packet. \end{DoxyCompactList}\item 
static uint16\+\_\+t \mbox{\hyperlink{compressor_8c_a67645e8b7174e226c4fd4892f81ae517}{compute\+\_\+length}} (unsigned char $\ast$data, uint16\+\_\+t data\+\_\+len)
\begin{DoxyCompactList}\small\item\em Set the packet length for the U\+DP and IP headers. \end{DoxyCompactList}\item 
static uint16\+\_\+t \mbox{\hyperlink{compressor_8c_aa4e0f02b97163cd6f8c09b6ac5736aa7}{chksum}} (uint16\+\_\+t sum, const uint8\+\_\+t $\ast$data, uint16\+\_\+t len)
\item 
uint16\+\_\+t \mbox{\hyperlink{compressor_8c_a89368d1a9e14855697684aa89b0f1aac}{compute\+\_\+checksum}} (unsigned char $\ast$data)
\begin{DoxyCompactList}\small\item\em Calculates the U\+DP checksum and sets the appropriate header fields. \end{DoxyCompactList}\item 
uint16\+\_\+t \mbox{\hyperlink{compressor_8c_a8af6027989d3e39cdcc37f16ff38d7ff}{schc\+\_\+decompress}} (\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$bit\+\_\+arr, uint8\+\_\+t $\ast$buf, uint32\+\_\+t device\+\_\+id, uint16\+\_\+t total\+\_\+length, \mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}} dir)
\begin{DoxyCompactList}\small\item\em Construct the header from the layered set of rules. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
static \mbox{\hyperlink{schc_8h_a871e6877df8d1bf5f1d0690d6b918f6b}{schc\+\_\+ipaddr\+\_\+t}} \mbox{\hyperlink{compressor_8c_af88fc53bc74390cc215e9b1548f38359}{node\+\_\+ip\+\_\+6}}
\item 
\mbox{\hyperlink{structjsmn__parser}{jsmn\+\_\+parser}} \mbox{\hyperlink{compressor_8c_a832436cdee822ecccd06537f5e889955}{json\+\_\+parser}}
\item 
\mbox{\hyperlink{structjsmntok__t}{jsmntok\+\_\+t}} \mbox{\hyperlink{compressor_8c_a6d19fbe1409f7470283881e0b642c417}{json\+\_\+token}} \mbox{[}\mbox{\hyperlink{schc__config__example_8h_a4e7d67d7aea26c4f57d1098595f90662}{J\+S\+O\+N\+\_\+\+T\+O\+K\+E\+NS}}\mbox{]}
\end{DoxyCompactItemize}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{compressor_8c_aa4e0f02b97163cd6f8c09b6ac5736aa7}\label{compressor_8c_aa4e0f02b97163cd6f8c09b6ac5736aa7}} 
\index{compressor.c@{compressor.c}!chksum@{chksum}}
\index{chksum@{chksum}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{chksum()}{chksum()}}
{\footnotesize\ttfamily static uint16\+\_\+t chksum (\begin{DoxyParamCaption}\item[{uint16\+\_\+t}]{sum,  }\item[{const uint8\+\_\+t $\ast$}]{data,  }\item[{uint16\+\_\+t}]{len }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

\mbox{\Hypertarget{compressor_8c_a965c3a63dd22c405c83c4164f10f9985}\label{compressor_8c_a965c3a63dd22c405c83c4164f10f9985}} 
\index{compressor.c@{compressor.c}!compress@{compress}}
\index{compress@{compress}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{compress()}{compress()}}
{\footnotesize\ttfamily static uint8\+\_\+t compress (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{dst,  }\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{src,  }\item[{const struct \mbox{\hyperlink{structschc__layer__rule__t}{schc\+\_\+layer\+\_\+rule\+\_\+t}} $\ast$}]{rule,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{DI }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



The compression mechanism. 


\begin{DoxyParams}{Parameters}
{\em dst\+\_\+arr} & the bit array in which to copy the contents to \\
\hline
{\em src\+\_\+arr} & the original header \\
\hline
{\em rule} & the rule to match the compression with\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the length length of the compressed header 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a89368d1a9e14855697684aa89b0f1aac}\label{compressor_8c_a89368d1a9e14855697684aa89b0f1aac}} 
\index{compressor.c@{compressor.c}!compute\_checksum@{compute\_checksum}}
\index{compute\_checksum@{compute\_checksum}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{compute\_checksum()}{compute\_checksum()}}
{\footnotesize\ttfamily uint16\+\_\+t compute\+\_\+checksum (\begin{DoxyParamCaption}\item[{unsigned char $\ast$}]{data }\end{DoxyParamCaption})}



Calculates the U\+DP checksum and sets the appropriate header fields. 


\begin{DoxyParams}{Parameters}
{\em data} & pointer to the data packet\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
checksum the computed checksum 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a67645e8b7174e226c4fd4892f81ae517}\label{compressor_8c_a67645e8b7174e226c4fd4892f81ae517}} 
\index{compressor.c@{compressor.c}!compute\_length@{compute\_length}}
\index{compute\_length@{compute\_length}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{compute\_length()}{compute\_length()}}
{\footnotesize\ttfamily static uint16\+\_\+t compute\+\_\+length (\begin{DoxyParamCaption}\item[{unsigned char $\ast$}]{data,  }\item[{uint16\+\_\+t}]{data\+\_\+len }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Set the packet length for the U\+DP and IP headers. 


\begin{DoxyParams}{Parameters}
{\em data} & pointer to the data packet \\
\hline
{\em data\+\_\+len} & the length of the total packet\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_af8317d5d5e72076851ec7fe49688f4a7}\label{compressor_8c_af8317d5d5e72076851ec7fe49688f4a7}} 
\index{compressor.c@{compressor.c}!decompress@{decompress}}
\index{decompress@{decompress}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{decompress()}{decompress()}}
{\footnotesize\ttfamily static uint8\+\_\+t decompress (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__layer__rule__t}{schc\+\_\+layer\+\_\+rule\+\_\+t}} $\ast$}]{rule,  }\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{src,  }\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{dst,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{DI }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



The decompression mechanism. 


\begin{DoxyParams}{Parameters}
{\em rule} & pointer to the rule to use during the decompression \\
\hline
{\em src} & the received S\+C\+HC bit buffer \\
\hline
{\em dst} & the buffer to store the decompressed, original packet\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the length of the decompressed header 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a9991f6ae222b8d657ebb0e0b162ea282}\label{compressor_8c_a9991f6ae222b8d657ebb0e0b162ea282}} 
\index{compressor.c@{compressor.c}!equal@{equal}}
\index{equal@{equal}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{equal()}{equal()}}
{\footnotesize\ttfamily static uint8\+\_\+t equal (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$}]{target\+\_\+field,  }\item[{unsigned char $\ast$}]{field\+\_\+value,  }\item[{uint16\+\_\+t}]{field\+\_\+offset }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



The equal matching operator. 


\begin{DoxyParams}{Parameters}
{\em target\+\_\+field} & the field from the rule \\
\hline
{\em field\+\_\+value} & the value from the header to compare with the rule value \\
\hline
{\em field\+\_\+offset} & the offset (in bits), starting from the field value pointer\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 if the target field matches the field value 0 if the target field doesn\textquotesingle{}t match the field value 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_ac9e32a3cb72316274db7b597a9aca407}\label{compressor_8c_ac9e32a3cb72316274db7b597a9aca407}} 
\index{compressor.c@{compressor.c}!get\_device\_by\_id@{get\_device\_by\_id}}
\index{get\_device\_by\_id@{get\_device\_by\_id}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{get\_device\_by\_id()}{get\_device\_by\_id()}}
{\footnotesize\ttfamily static struct \mbox{\hyperlink{structschc__device}{schc\+\_\+device}}$\ast$ get\+\_\+device\+\_\+by\+\_\+id (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{device\+\_\+id }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Get a device by it\textquotesingle{}s id. 


\begin{DoxyParams}{Parameters}
{\em device\+\_\+id} & the id of the device\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
\mbox{\hyperlink{structschc__device}{schc\+\_\+device}} the device which is found N\+U\+LL if no device was found 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_ac1569580e90e636a6d48366af83f3164}\label{compressor_8c_ac1569580e90e636a6d48366af83f3164}} 
\index{compressor.c@{compressor.c}!get\_node\_ip@{get\_node\_ip}}
\index{get\_node\_ip@{get\_node\_ip}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{get\_node\_ip()}{get\_node\_ip()}}
{\footnotesize\ttfamily static void get\+\_\+node\+\_\+ip (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{schc_8h_a871e6877df8d1bf5f1d0690d6b918f6b}{schc\+\_\+ipaddr\+\_\+t}} $\ast$}]{node\+\_\+ip }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Get the node its IP address as set during initialization. 

\begin{DoxyReturn}{Returns}
node\+\_\+ip\+\_\+6 the node its IP address 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_ab1cdc4ecc8218636dd177a43cf85bb63}\label{compressor_8c_ab1cdc4ecc8218636dd177a43cf85bb63}} 
\index{compressor.c@{compressor.c}!get\_schc\_rule\_by\_layer\_ids@{get\_schc\_rule\_by\_layer\_ids}}
\index{get\_schc\_rule\_by\_layer\_ids@{get\_schc\_rule\_by\_layer\_ids}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{get\_schc\_rule\_by\_layer\_ids()}{get\_schc\_rule\_by\_layer\_ids()}}
{\footnotesize\ttfamily static struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}}$\ast$ get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+layer\+\_\+ids (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{ip\+\_\+rule\+\_\+id,  }\item[{uint8\+\_\+t}]{udp\+\_\+rule\+\_\+id,  }\item[{uint8\+\_\+t}]{coap\+\_\+rule\+\_\+id,  }\item[{uint32\+\_\+t}]{device\+\_\+id,  }\item[{\mbox{\hyperlink{schc_8h_a00b61f9b90ab7065eb6a978141d7fd34}{reliability\+\_\+mode}}}]{mode }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}

\mbox{\Hypertarget{compressor_8c_aaf76c0525a94eecb1f694ba09b435c49}\label{compressor_8c_aaf76c0525a94eecb1f694ba09b435c49}} 
\index{compressor.c@{compressor.c}!get\_schc\_rule\_by\_reliability\_mode@{get\_schc\_rule\_by\_reliability\_mode}}
\index{get\_schc\_rule\_by\_reliability\_mode@{get\_schc\_rule\_by\_reliability\_mode}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{get\_schc\_rule\_by\_reliability\_mode()}{get\_schc\_rule\_by\_reliability\_mode()}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}}$\ast$ get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+reliability\+\_\+mode (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$}]{schc\+\_\+rule,  }\item[{\mbox{\hyperlink{schc_8h_a00b61f9b90ab7065eb6a978141d7fd34}{reliability\+\_\+mode}}}]{mode,  }\item[{uint32\+\_\+t}]{device\+\_\+id }\end{DoxyParamCaption})}

\mbox{\Hypertarget{compressor_8c_a0403165232716bdd5f3a06169692c2a9}\label{compressor_8c_a0403165232716bdd5f3a06169692c2a9}} 
\index{compressor.c@{compressor.c}!get\_schc\_rule\_by\_rule\_id@{get\_schc\_rule\_by\_rule\_id}}
\index{get\_schc\_rule\_by\_rule\_id@{get\_schc\_rule\_by\_rule\_id}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{get\_schc\_rule\_by\_rule\_id()}{get\_schc\_rule\_by\_rule\_id()}}
{\footnotesize\ttfamily struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}}$\ast$ get\+\_\+schc\+\_\+rule\+\_\+by\+\_\+rule\+\_\+id (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{rule\+\_\+arr,  }\item[{uint32\+\_\+t}]{device\+\_\+id }\end{DoxyParamCaption})}

\mbox{\Hypertarget{compressor_8c_a394540a77045dcb0230079435b631960}\label{compressor_8c_a394540a77045dcb0230079435b631960}} 
\index{compressor.c@{compressor.c}!ignore@{ignore}}
\index{ignore@{ignore}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{ignore()}{ignore()}}
{\footnotesize\ttfamily static uint8\+\_\+t ignore (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$}]{target\+\_\+field,  }\item[{unsigned char $\ast$}]{field\+\_\+value,  }\item[{uint16\+\_\+t}]{field\+\_\+offset }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



The ignore matching operator. 


\begin{DoxyParams}{Parameters}
{\em target\+\_\+field} & the field from the rule \\
\hline
{\em field\+\_\+value} & the value from the header to compare with the rule value\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a5371dbc9847ed58dc760b7f028ea14e9}\label{compressor_8c_a5371dbc9847ed58dc760b7f028ea14e9}} 
\index{compressor.c@{compressor.c}!matchmap@{matchmap}}
\index{matchmap@{matchmap}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{matchmap()}{matchmap()}}
{\footnotesize\ttfamily static uint8\+\_\+t matchmap (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$}]{target\+\_\+field,  }\item[{unsigned char $\ast$}]{field\+\_\+value,  }\item[{uint16\+\_\+t}]{field\+\_\+offset }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



The match-\/map matching operator match-\/mapping\+: With match-\/mapping, the Target Value is a list of values. 

Each value of the list is identified by an index. Compression is achieved by sending the index instead of the original header field value.


\begin{DoxyParams}{Parameters}
{\em target\+\_\+field} & the field from the rule \\
\hline
{\em field\+\_\+value} & the value from the header to compare with the rule value\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 if the the field value is equal to one of the values found in the mapping array 0 if no matching value is found in the mapping array 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_abd91def21b62074e08368e9bb11593d5}\label{compressor_8c_abd91def21b62074e08368e9bb11593d5}} 
\index{compressor.c@{compressor.c}!MSB@{MSB}}
\index{MSB@{MSB}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{MSB()}{MSB()}}
{\footnotesize\ttfamily static uint8\+\_\+t M\+SB (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__field}{schc\+\_\+field}} $\ast$}]{target\+\_\+field,  }\item[{unsigned char $\ast$}]{field\+\_\+value,  }\item[{uint16\+\_\+t}]{field\+\_\+offset }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



The M\+SB matching operator M\+S\+B(x)\+: a match is obtained if the most significant (leftmost) x bits of the packet header field value are equal to the TV in the Rule. 

The x parameter of the M\+SB MO indicates how many bits are involved in the comparison. If the FL is described as variable, the x parameter must be a multiple of the FL unit. For example, x must be multiple of 8 if the unit of the variable length is bytes.


\begin{DoxyParams}{Parameters}
{\em target\+\_\+field} & the field from the rule \\
\hline
{\em field\+\_\+value} & the value from the header to compare with the rule value\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
1 if the M\+SB of the target field matches the M\+SB of the field value 0 if the M\+SB of the target field doesn\textquotesingle{}t match the M\+SB of the field value 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a7b8fe3cf10dcb9935bcbc92bb1b9c8f9}\label{compressor_8c_a7b8fe3cf10dcb9935bcbc92bb1b9c8f9}} 
\index{compressor.c@{compressor.c}!schc\_compress@{schc\_compress}}
\index{schc\_compress@{schc\_compress}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{schc\_compress()}{schc\_compress()}}
{\footnotesize\ttfamily int16\+\_\+t schc\+\_\+compress (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{data,  }\item[{uint16\+\_\+t}]{total\+\_\+length,  }\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{dst,  }\item[{uint32\+\_\+t}]{device\+\_\+id,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{dir,  }\item[{struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$$\ast$}]{schc\+\_\+rule }\end{DoxyParamCaption})}



Compresses a Co\+A\+P/\+U\+D\+P/\+IP packet. 


\begin{DoxyParams}{Parameters}
{\em data} & pointer to the original packet \\
\hline
{\em total\+\_\+length} & the length of the packet \\
\hline
{\em dst} & pointer to the bit array object, where the compressed packet will be stored. Can later be passed to fragmenter \\
\hline
{\em device\+\_\+id} & the device id to find a rule for \\
\hline
{\em direction} & the direction of the flow UP\+: L\+P\+W\+AN to I\+Pv6 or D\+O\+WN\+: I\+Pv6 to L\+P\+W\+AN \\
\hline
{\em device\+\_\+type} & the device type\+: N\+E\+T\+W\+O\+R\+K\+\_\+\+G\+A\+T\+E\+W\+AY or D\+E\+V\+I\+CE \\
\hline
{\em schc\+\_\+rule} & a pointer to a schc rule struct to return the rule that was found\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
length the length of the compressed packet -\/1 on a memory overflow
\end{DoxyReturn}
\begin{DoxyNote}{Note}
the compressor will only look for rules configured with the N\+O\+T\+\_\+\+F\+R\+A\+G\+M\+E\+N\+T\+ED reliability mode 
\end{DoxyNote}
\mbox{\Hypertarget{compressor_8c_a4fd03f3acd56b4bf55fc4c8e48567ab7}\label{compressor_8c_a4fd03f3acd56b4bf55fc4c8e48567ab7}} 
\index{compressor.c@{compressor.c}!schc\_compressor\_init@{schc\_compressor\_init}}
\index{schc\_compressor\_init@{schc\_compressor\_init}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{schc\_compressor\_init()}{schc\_compressor\_init()}}
{\footnotesize\ttfamily uint8\+\_\+t schc\+\_\+compressor\+\_\+init (\begin{DoxyParamCaption}\item[{uint8\+\_\+t}]{src\mbox{[}16\mbox{]} }\end{DoxyParamCaption})}



Initializes the S\+C\+HC compressor. 


\begin{DoxyParams}{Parameters}
{\em node\+\_\+ip} & a pointer to the source it\textquotesingle{}s ip address\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
error error codes on error 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a8af6027989d3e39cdcc37f16ff38d7ff}\label{compressor_8c_a8af6027989d3e39cdcc37f16ff38d7ff}} 
\index{compressor.c@{compressor.c}!schc\_decompress@{schc\_decompress}}
\index{schc\_decompress@{schc\_decompress}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{schc\_decompress()}{schc\_decompress()}}
{\footnotesize\ttfamily uint16\+\_\+t schc\+\_\+decompress (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{bit\+\_\+arr,  }\item[{uint8\+\_\+t $\ast$}]{buf,  }\item[{uint32\+\_\+t}]{device\+\_\+id,  }\item[{uint16\+\_\+t}]{total\+\_\+length,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{dir }\end{DoxyParamCaption})}



Construct the header from the layered set of rules. 


\begin{DoxyParams}{Parameters}
{\em data} & pointer to the received data \\
\hline
{\em buf} & pointer where to save the decompressed packet \\
\hline
{\em device\+\_\+id} & the device its id \\
\hline
{\em total\+\_\+length} & the total length of the received data \\
\hline
{\em direction} & the direction of the flow (UP\+: L\+P\+W\+AN to I\+Pv6, D\+O\+WN\+: I\+Pv6 to L\+P\+W\+AN)\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
length length of the newly constructed packet 0 the rule was not found 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a8137a81bb5ae333086b8aaf814b10a62}\label{compressor_8c_a8137a81bb5ae333086b8aaf814b10a62}} 
\index{compressor.c@{compressor.c}!schc\_find\_rule\_from\_header@{schc\_find\_rule\_from\_header}}
\index{schc\_find\_rule\_from\_header@{schc\_find\_rule\_from\_header}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{schc\_find\_rule\_from\_header()}{schc\_find\_rule\_from\_header()}}
{\footnotesize\ttfamily static struct \mbox{\hyperlink{structschc__layer__rule__t}{schc\+\_\+layer\+\_\+rule\+\_\+t}}$\ast$ schc\+\_\+find\+\_\+rule\+\_\+from\+\_\+header (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{structschc__bitarray__t}{schc\+\_\+bitarray\+\_\+t}} $\ast$}]{src,  }\item[{uint32\+\_\+t}]{device\+\_\+id,  }\item[{\mbox{\hyperlink{schc_8h_ac6a26bb50f32ca8810179e894e284ea0}{schc\+\_\+layer\+\_\+t}}}]{layer,  }\item[{\mbox{\hyperlink{schc_8h_a99f26e6ee9fcd62f75203b5402df8098}{direction}}}]{DI }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Find a matching rule for a layer. 


\begin{DoxyParams}{Parameters}
{\em schc\+\_\+bitarray} & the bit array as received from the network note\+: a conversion is required for Co\+AP to decode the options\\
\hline
{\em device\+\_\+id} & the device to find an IP rule for \\
\hline
{\em schc\+\_\+layer} & the layer for which to find a rule for\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the rule N\+U\+LL if no rule is found 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a3e74925e4bb4cb937a3ac4b951f41119}\label{compressor_8c_a3e74925e4bb4cb937a3ac4b951f41119}} 
\index{compressor.c@{compressor.c}!set\_node\_ip@{set\_node\_ip}}
\index{set\_node\_ip@{set\_node\_ip}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{set\_node\_ip()}{set\_node\_ip()}}
{\footnotesize\ttfamily static void set\+\_\+node\+\_\+ip (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{schc_8h_a871e6877df8d1bf5f1d0690d6b918f6b}{schc\+\_\+ipaddr\+\_\+t}} $\ast$}]{node\+\_\+ip }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Notifies the compressor about the node its IP address. 


\begin{DoxyParams}{Parameters}
{\em node\+\_\+ip} & pointer to the ip address array\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 
\end{DoxyReturn}
\mbox{\Hypertarget{compressor_8c_a15002a02e9cae01e5629cb2d474fe482}\label{compressor_8c_a15002a02e9cae01e5629cb2d474fe482}} 
\index{compressor.c@{compressor.c}!set\_rule\_id@{set\_rule\_id}}
\index{set\_rule\_id@{set\_rule\_id}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{set\_rule\_id()}{set\_rule\_id()}}
{\footnotesize\ttfamily int8\+\_\+t set\+\_\+rule\+\_\+id (\begin{DoxyParamCaption}\item[{struct \mbox{\hyperlink{structschc__rule__t}{schc\+\_\+rule\+\_\+t}} $\ast$}]{schc\+\_\+rule,  }\item[{uint8\+\_\+t $\ast$}]{data }\end{DoxyParamCaption})}

\mbox{\Hypertarget{compressor_8c_a263bfe2b1b6914b5b715f434f154d07b}\label{compressor_8c_a263bfe2b1b6914b5b715f434f154d07b}} 
\index{compressor.c@{compressor.c}!swap\_ipv6\_source\_and\_destination@{swap\_ipv6\_source\_and\_destination}}
\index{swap\_ipv6\_source\_and\_destination@{swap\_ipv6\_source\_and\_destination}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{swap\_ipv6\_source\_and\_destination()}{swap\_ipv6\_source\_and\_destination()}}
{\footnotesize\ttfamily static void swap\+\_\+ipv6\+\_\+source\+\_\+and\+\_\+destination (\begin{DoxyParamCaption}\item[{uint8\+\_\+t $\ast$}]{ptr }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



Swaps the I\+Pv6 source and destination. 


\begin{DoxyParams}{Parameters}
{\em ptr} & pointer to the ipv6 header \\
\hline
\end{DoxyParams}


\doxysubsection{Variable Documentation}
\mbox{\Hypertarget{compressor_8c_a832436cdee822ecccd06537f5e889955}\label{compressor_8c_a832436cdee822ecccd06537f5e889955}} 
\index{compressor.c@{compressor.c}!json\_parser@{json\_parser}}
\index{json\_parser@{json\_parser}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{json\_parser}{json\_parser}}
{\footnotesize\ttfamily \mbox{\hyperlink{structjsmn__parser}{jsmn\+\_\+parser}} json\+\_\+parser}

\mbox{\Hypertarget{compressor_8c_a6d19fbe1409f7470283881e0b642c417}\label{compressor_8c_a6d19fbe1409f7470283881e0b642c417}} 
\index{compressor.c@{compressor.c}!json\_token@{json\_token}}
\index{json\_token@{json\_token}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{json\_token}{json\_token}}
{\footnotesize\ttfamily \mbox{\hyperlink{structjsmntok__t}{jsmntok\+\_\+t}} json\+\_\+token\mbox{[}\mbox{\hyperlink{schc__config__example_8h_a4e7d67d7aea26c4f57d1098595f90662}{J\+S\+O\+N\+\_\+\+T\+O\+K\+E\+NS}}\mbox{]}}

\mbox{\Hypertarget{compressor_8c_af88fc53bc74390cc215e9b1548f38359}\label{compressor_8c_af88fc53bc74390cc215e9b1548f38359}} 
\index{compressor.c@{compressor.c}!node\_ip\_6@{node\_ip\_6}}
\index{node\_ip\_6@{node\_ip\_6}!compressor.c@{compressor.c}}
\doxysubsubsection{\texorpdfstring{node\_ip\_6}{node\_ip\_6}}
{\footnotesize\ttfamily \mbox{\hyperlink{schc_8h_a871e6877df8d1bf5f1d0690d6b918f6b}{schc\+\_\+ipaddr\+\_\+t}} node\+\_\+ip\+\_\+6\hspace{0.3cm}{\ttfamily [static]}}

